package com.example.xm.servive.impl;

import com.example.xm.Entity.Mail;
import com.example.xm.config.PageResult;
import com.example.xm.mapper.MailMapper;
import com.example.xm.servive.MailServive;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MailServiveImpl implements MailServive {

    @Autowired
    MailMapper mailMapper;

    @Override
    public List<Mail> getMail(Mail mail) {
        return mailMapper.getMail(mail);
    }

    @Override
    public int Add(Mail mail) {
        return mailMapper.Add(mail);
    }

    /**
     * 分页
     * */
    @Override
    public PageResult selectPager(int pageNum, int pageSize, Mail mail) {
        //开始分页，指定页码与每页记录数
        PageHelper.startPage(pageNum,pageSize);
        //执行查询，请求会被分页插件拦截
        List<Mail> students = mailMapper.getMail(mail);
        //返回分页对象与数据
        return PageResult.getPageResult(new PageInfo<Mail>(students));
    }

    @Override
    public int del(String id) {
        return mailMapper.del(id);
    }


    @Override
    public Mail getMailId(String qq) {
        return mailMapper.getMailId(qq);
    }

    @Override
    public int Update(Mail mail) {
        return mailMapper.Update(mail);
    }

}
